package cn.tedu.fresheveryday.service.impl;

import cn.tedu.fresheveryday.exception.ServiceException;
import cn.tedu.fresheveryday.mapper.OrderMapper;
import cn.tedu.fresheveryday.mapper.OrderStatusHistoryMapper;
import cn.tedu.fresheveryday.pojo.entity.Order;
import cn.tedu.fresheveryday.pojo.vo.OrderStatusHistoryVO;
import cn.tedu.fresheveryday.restful.ResponseCode;
import cn.tedu.fresheveryday.service.IOderStatusHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderStatusHistoryServiceImpl implements IOderStatusHistoryService {
    @Autowired
    OrderStatusHistoryMapper mapper;

    @Autowired
    OrderMapper orderMapper;

    @Override
    public List<OrderStatusHistoryVO> selectByOrderId(String orderId) {
        // 通过订单号查询订单
        Order order = orderMapper.selectByOrderId(orderId);

        if (order == null) {
            throw new ServiceException(ResponseCode.BAD_REQUEST, "订单不存在");
        }

        return mapper.selectByOrderId(orderId);
    }

}